home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / stores.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  4KB  |  186 lines

  1. /* --------------------------------- stores.c ------------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* Show stores (HDD_STORES).
  8. */
  9.  
  10. #include "plane.h"
  11.  
  12.  
  13. /* Status is:
  14.  *
  15.  * blank    retracted.
  16.  * L        lowered
  17.  * G        has ground contact
  18.  * green    fully extended, safe
  19.  * red        in transit, unsafe
  20. */
  21. LOCAL_FUNC int FAR
  22. show_gear (int x, int y, short pos, Ushort ground, int s)
  23. {
  24.     int    c, color;
  25.  
  26.     c = (0 == pos) ? ' ' : (ground ? 'G' : 'L');
  27.     color = (100 == pos) ? CC_GREEN : CC_RED;
  28.     return (stroke_char (x, y, c, s, color));
  29. }
  30.  
  31. extern void FAR
  32. show_stores (VIEW *view, OBJECT *p, int maxx, int maxy, int orgx, int orgy,
  33.     int ss)
  34. {
  35.     int    hud, hud1, knots, blink;
  36.     Ushort    equip;
  37.     int    xl, xr, x, y, x0, y0, tx, ty, dd;
  38.     int    i, t, mm, hh;
  39.     long    range = 0;
  40.  
  41.     hud = EX->hud;
  42.     hud1 = EX->hud1;
  43.     knots = hud1 & HUD_KNOTS;
  44.     equip = EX->equip;
  45.     blink = ((int)st.present)&0x0080;
  46.  
  47.     dd = num_size (9L, ss);
  48.     xl = orgx - maxx + 2;
  49.     xr = orgx;
  50.     y = orgy - maxy + ss;
  51.     y0 = (ss*3) >> 1;
  52.  
  53. /* Show fuel status.
  54. */
  55.     y += ss;
  56.     x0 = xl;
  57.     t = (int) (EX->fuel / EP->fuel_capacity);
  58.     x0 += stroke_str (x0, y, "FUEL ", ss, (t < 10) ? CC_RED : CC_GREEN);
  59.     stroke_num (x0, y, EX->fuel/100, ss, ST_HFG);
  60.  
  61.     y += y0;
  62.     x0 = xl;
  63.     x0 += stroke_str  (x0, y, "TIME ", ss, ST_HFG);
  64.     t = EX->fuelRate;
  65.     if (t) {
  66.         mm = (int)(EX->fuel / (60L*t));
  67.         range = p->speed/VONE * 60L * mm;
  68.         hh = mm / 60;
  69.         mm -= 60*hh;
  70.         if (hh > 99)
  71.             hh = mm = 99;
  72.         x0 += stroke_num  (x0, y, hh, ss, ST_HFG);
  73.         x0 += stroke_char (x0, y, ':', ss, ST_HFG);
  74.         stroke_frac (x0, y, mm, 2, 0, ss, ST_HFG);
  75.     }
  76.  
  77.     y += y0;
  78.     x0 = xl;
  79.     x0 += stroke_str (x0, y, "RNGE ", ss, ST_HFG);
  80.     if (t) {
  81.         range /= knots ? 1852L : 1000L;
  82.         stroke_num (x0, y, range, ss, ST_HFG);
  83.     }
  84.  
  85. /* Show gear status.
  86. */
  87.     y += y0;
  88.     x0 = xl;
  89.     x0 += stroke_str (x0, y, "GEAR ", ss, ST_HFG);
  90.     x0 += show_gear  (x0, y, EX->gear[0], equip & EQ_GEAR1, ss);
  91.     x0 += show_gear  (x0, y, EX->gear[1], equip & EQ_GEAR2, ss);
  92.     x0 += show_gear  (x0, y, EX->gear[2], equip & EQ_GEAR3, ss);
  93.     x0 += show_gear  (x0, y, EX->gear[3], equip & EQ_GEAR4, ss);
  94.     x0 += show_gear  (x0, y, EX->gear[4], equip & EQ_GEAR5, ss);
  95.  
  96. /* Show other digital stuff.
  97. */
  98.     y = orgy + maxy - ss;
  99.  
  100.     x0 = xl;
  101.     x0 += stroke_str (x0, y, "SPL ", ss, ST_HFG);
  102.     if (EX->spoilers)
  103.         stroke_num (x0, y, EX->spoilers, ss, ST_HFG);
  104.     y -= y0;
  105.  
  106.     x0 = xl;
  107.     x0 += stroke_str (x0, y, "FLP ", ss, ST_HFG);
  108.     if (EX->flaps)
  109.         stroke_num (x0, y, EX->flaps, ss, ST_HFG);
  110.     y -= y0;
  111.  
  112.     x0 = xl;
  113.     x0 += stroke_str (x0, y, "RDR ", ss, ST_HFG);
  114.     if (EX->rudder) {
  115.         x0 += stroke_char (x0, y, (EX->rudder > 0) ? 'L' : 'R', ss,
  116.             ST_HFG);
  117.         t = abs(EX->rudder);
  118.          stroke_num (x0, y, t , ss, ST_HFG);
  119.     }
  120.     y -= y0;
  121.  
  122.     if (EX->brake) {
  123.         x0 = xl;
  124.         x0 += stroke_str (x0, y, "BRK ", ss, ST_HFG);
  125.         stroke_num (x0, y, EX->brake, ss, ST_HFG);
  126.     }
  127.     y -= y0;
  128.  
  129.     x0 = xl;
  130.     if (EX->flags & PF_CHASE)
  131.         x0 += stroke_str (x0, y, EX->target ? "CHASE " :"AUTO ",
  132.             ss, ST_HFG);
  133.     else
  134.         x0 += 5*dd;
  135.     if (EX->flags & PF_KILL)
  136.         stroke_str (x0, y, "KILL", ss, ST_HFG);
  137.     y -= y0;
  138.  
  139.     x0 = xl;
  140.     x0 += stroke_str (x0, y, "HLT ", ss, ST_HFG);
  141.     stroke_num (x0, y, p->damage, ss,
  142.                 (p->damage <= 3) ? CC_RED : ST_HFG);
  143.     y -= y0;
  144.  
  145. /* Show weapons.
  146. */
  147.     y = orgy - maxy + ss;
  148.     for (i = 1; i <= WE_LAST; ++i) {
  149.         y += y0;
  150.         stroke_str (xr, y, get_wname (i), ss, CC_GREEN);
  151.         x0 = xr + 6*dd;
  152.         x0 += stroke_num (x0, y, EX->stores[i-1], ss, ST_HFG);
  153.         if (EX->weapon == i)
  154.             show_rect ((xr+x0)>>1, y-(ss>>1),
  155.                 ((x0-xr)>>1)+2, (ss>>1)+2, CC_GREEN, 0);
  156.     }
  157.  
  158. /* Show throttle and power
  159. */
  160.     tx = maxx >> 5;
  161.     ty = maxy >> 5;
  162.     x = orgx + maxx - tx - 4;        /* position */
  163.     y = orgy + maxy;            /* bottom */
  164.     y0 = maxy + maxy - ss - ty;        /* height */
  165.  
  166.     gr_color (ST_HFG);
  167.     gr_move (x, y);                /* reference bar */
  168.     gr_draw (x, y-y0);
  169.  
  170.     if (100 == EX->throttle)
  171.         t = 75 + muldiv (EX->afterburner, 100-75, 100);
  172.     else {
  173.         t = muldiv (EX->throttle, 75, 100);
  174.         if (t < 0) {
  175.             t = -t;
  176.         }
  177.     }
  178.     t = muldiv (t, y0, 100);
  179.     if (!EX->airbrake || blink)
  180.         show_trig (x-tx, y-t, tx, ty, ST_HFG);    /* throttle */
  181.  
  182.     t = muldiv (EX->power, y0, 10000);
  183.     gr_move (x,    y-t);            /* power */
  184.     gr_draw (x+tx, y-t);
  185. }
  186.